/**
 * 
 */
package Util;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @author zhaoyana
 *
 */
public class DBUtils {

	/**
	 * @param sql
	 * @param name
	 * @param password
	 * @return
	 */
	private static String dbUrl="jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone = GMT"; // ���ݿ����ӵ�ַ
	private static String dbUserName="root"; // 用户名
	private static String dbPassword="123456"; // 密码
	private static String jdbcName="com.mysql.jdbc.Driver"; // 地址
	
	/**
	 * 连接数据库
	 * @return
	 * @throws Exception
	 */
	public static Connection getCon()throws Exception{
		Class.forName(jdbcName);
		Connection con=DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
		return con;
	}
	
	/**
	 * �ر����ݿ�����
	 * @param con
	 * @throws Exception
	 */
	public static void closeCon(Connection con)throws Exception{
		if(con!=null){
			con.close();
		}
	}
	
	public static void main(String[] args) {
		DbCUtil dbUtil=new DbCUtil();
		try {
			dbUtil.getCon();
			System.out.println("连接成功");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("不成功");
		}
	}
	}

